({
    data: {
        resultdata: {},
        dbConn: Program.data.dbConn,
        WorkId: Program.data.WorkId,
        requestBody: Program.data.requestBody,
        CartModel: {
            model: {
                CartId: 0,
                UserId: "",
                GoodsId: 0,
                Num: 0,
                Status: 0,
                SpecName: "",
                SpecDetailId: 0,
                WorkId: 0,
                CreateTime: "yyyy-MM-dd HH:mm:ss",
                UpdateTime: "yyyy-MM-dd HH:mm:ss",
                IsChecked: 0
            },
            tablename: "Mall_Cart",
            key: "CartId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        OrderModel: {
            model: {
                OrderId: 0,
                OrderNo: "",
                PayState: 0,
                PayType: 0,
                TotalFee: 0,
                OrderStatus: 0,
                CreateTime: "yyyy-MM-dd HH:mm:ss",
                OrderMemo: "",
                UserId: "",
                DelFlag: 0,
                WorkId: 0,
            },
            tablename: "Mall_Order",
            key: "OrderId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        OrderGoodsModel: {
            model: {
                OrderGoodsId: 0,
                ShopId: 0,
                ShopName: "",
                GoodsId: 0,
                GoodsName: "",
                GoodsPrice: 0,
                GoodsNum: 0,
                SpecName: "",
                SpecDetailId: 0,
                SpecImg: "",
                OrderNo: "",
                Status: 0
            },
            tablename: "Mall_OrderGoods",
            key: "OrderGoodsId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        OrderAddressModel: {
            model: {
                OrderReceiverId: 0,
                OrderNo: "",
                Name: "",
                TelePhone: "",
                Province: "",
                City: "",
                Area: "",
                Address: ""
            },
            tablename: "Mall_OrderAddress",
            key: "OrderReceiverId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        GoodsSpecDetailModel: {
            model: {
                GoodsSpecDetailId: 0,
                GoodsId: 0,
                SpecCom: "",
                SpecItemCom: "",
                ProductSpec: "",
                GoodsStock: 0,
                GoodsRetailPrice: 0,
                GoodsMarketPrice: 0,
                GoodsSpecImg: ""

            },
            tablename: "Mall_GoodsSpecDetail",
            key: "GoodsSpecDetailId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        MemberModel: {
            model: {
                Id: 0,
                UserId: "",
                NickName: "",
                UserImg: "",
                TelPhone: "",
                DelFlag: 0
            },
            tablename: "Mall_Member",
            key: "Id",
            val: "0",
            objval: {}
        },
        OrderPayModel: {
            model: {
                OrderPayId: 0,
                PayDate: "yyyy-MM-dd HH:mm:ss",
                PayFee: 0,
                OrderNo: "",
                TradeNo: "",
                MchId: "",
                BankType: "",
                TimeEnd: "yyyy-MM-dd HH:mm:ss",
            },
            tablename: "Mall_OrderPay",
            key: "OrderPayId",
            val: "0",
            objval: {}
        },
        RefundModel: {
            model: {
                RefundId: 0,
                RefundNo: "",
                OrderNo: "",
                RefundDate: "yyyy-MM-dd HH:mm:ss",
                RefundFee: 0,
                RefundType: 0,
                CargoStatus: 0,
                RefundStatus: 0,
                RefundDesc: "",
                TradeNo: "",
                SuccessTime: "yyyy-MM-dd HH:mm:ss",
                RefundRequestSource: 0,
                WorkId: 0,
                BillNo: "",
                RemoveShareBillNo: "",
                AuditTime: "yyyy-MM-dd HH:mm:ss",
                AuditStatus: 0,
                RefundMemo: "",
                Imgs: "",
                UserId: "",
                AuditMemo: "",
            },
            tablename: "Mall_Refund",
            key: "RefundId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        RefundLogModel: {
            model: {
                LogId: 0,
                OrderNo: "",
                RefundNo: "",
                Memo: "",
                OperationTime: "yyyy-MM-dd HH:mm:ss",
                Operator: "",
            },
            tablename: "Mall_RefundLog",
            key: "LogId",
            val: "0",
            objval: {},
        },
        RefundGoodsModel: {
            model: {
                RefundGoodsId: 0,
                ShopId: 0,
                ShopName: "",
                GoodsId: 0,
                GoodsName: "",
                GoodsPrice: 0,
                GoodsNum: 0,
                SpecName: "",
                SpecDetailId: 0,
                SpecImg: "",
                OrderNo: "",
                RefundNo: "",
            },
            tablename: "Mall_RefundGoods",
            key: "RefundGoodsId",
            val: "0",
            objval: {},
        },
        OrderEvaluateModel: {
            model: {
                OrderEvaluateId: 0,
                UserId: 0,
                GoodsId: 0,
                SpecDetailId: 0,
                SpecName: "",
                OrderNo: "",
                Star: 0,
                UserName: "",
                UserImage: "",
                Cont: "",
                Imgs: "",
                EvaluateTime: "yyyy-MM-dd HH:mm:ss",
                PublishStatus: 0,
                WorkId: 0,
            },
            tablename: "Mall_OrderEvaluate",
            key: "OrderEvaluateId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        OrderLogisticsModel: {
            model: {
                OrderLogisticsId: 0,
                RefundNo: "",
                OrderNo: "",
                LogisticsNo: "",
                LogisticsCompany: "",
                Status: 0,
                Fee: 0,
            },
            tablename: "Mall_OrderLogistics",
            key: "OrderLogisticsId",
            val: "0",
            objval: {},
        }
    },
    //实现增删改查示例API控制器
    main: function (funname) {
        var self = this;
        self.data.dbConn = PublicFunction.setdbconn('10.0.4.5:1433', 'CloudMall', 'sa', 'Lobster@123');
        //查询
        if (funname == "mall.getgoodslist") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var searchkey = LobsterAPI.RequestQuery("searchkey", "");
            var classId = LobsterAPI.RequestQuery("classId", -1);
            var sortkey = LobsterAPI.RequestQuery("sortkey", "");
            self.data.resultdata = self.getgoodslist(page, limit, searchkey, classId, sortkey);
        } else if (funname == "mall.getgoodsdetail") {
            var goodsId = LobsterAPI.RequestQuery("goodsId", 1);
            self.data.resultdata = self.getgoodsdetail(goodsId);
        } else if (funname == "mall.getevaluatelist") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var goodsId = LobsterAPI.RequestQuery("goodsId", 1);
            self.data.resultdata = self.getevaluatelist(page, limit, goodsId);
        } else if (funname == "mall.getspeclist") {
            var goodsId = LobsterAPI.RequestQuery("goodsId", 1);
            self.data.resultdata = self.getspeclist(goodsId);
        } else if (funname == "mall.getcartcount") {
            var userId = LobsterAPI.RequestQuery("userId", 1);
            self.data.resultdata = self.getcartcount(userId);
        } else if (funname == "mall.getcartlist") {
            var userId = LobsterAPI.RequestQuery("userId", 1);
            self.data.resultdata = self.getcartlist(userId);
        } else if (funname == "mall.addcart") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.addcart(model);
        } else if (funname == "mall.updatecartchecked") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.updatecartchecked(model);
        } else if (funname == "mall.updatecartnum") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.updatecartnum(model);
        } else if (funname == "mall.updatecartspec") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.updatecartspec(model);
        } else if (funname == "mall.removecart") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.removecart(model);
        } else if (funname == "mall.getorderinfo") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 1);
            self.data.resultdata = self.getorderinfo(orderNo);
        } else if (funname == "mall.generateorder") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.generateorder(model);
        } else if (funname == "mall.savemember") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.savemember(model);
        } else if (funname == "mall.getorderlist") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var orderStatus = LobsterAPI.RequestQuery("orderStatus", -1);
            var userId = LobsterAPI.RequestQuery("userId", "");
            self.data.resultdata = self.getorderlist(page, limit, orderStatus, userId);
        } else if (funname == "mall.paysuccess") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.paysuccess(model);
        } else if (funname == "mall.getorderaddressbyorderno") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 1);
            self.data.resultdata = self.getorderaddressbyorderno(orderNo);
        }
        else if (funname == "mall.getordergoodslist") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 1);
            self.data.resultdata = self.getordergoodslist(orderNo);
        }
        else if (funname == "mall.getrefundlistbyorderno") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 1);
            self.data.resultdata = self.getrefundlistbyorderno(orderNo);
        }
        else if (funname == "mall.getorderlogisticsbyorderno") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 1);
            self.data.resultdata = self.getorderlogisticsbyorderno(orderNo);
        } else if (funname == "mall.refund") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.refund(model);
        }
        else if (funname == "mall.UpdateOrderStatus") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 0);
            var orderStatus = LobsterAPI.RequestQuery("orderStatus", 0);
            self.data.resultdata = self.UpdateOrderStatus(orderNo, orderStatus);
        }
        else if (funname == "mall.GetEvaluateListByOrderNo") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 0);
            self.data.resultdata = self.GetEvaluateListByOrderNo(orderNo);
        }
        else if (funname == "mall.GetEvaluateDetail") {
            var orderNo = LobsterAPI.RequestQuery("orderNo", 0);
            var goodsId = LobsterAPI.RequestQuery("goodsId", 0);
            var specDetailId = LobsterAPI.RequestQuery("specDetailId", 0);
            self.data.resultdata = self.GetEvaluateDetail(orderNo, goodsId, specDetailId);
        }
        else if (funname == "mall.SaveEvaluate") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.SaveEvaluate(model);
        }
        else if (funname == "mall.GetRefundList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var userId = LobsterAPI.RequestQuery("userId", 0);
            self.data.resultdata = self.GetRefundList(page, limit, userId);
        }
        else if (funname == "mall.GetRefundLogByRefundNo") {
            var refundNo = LobsterAPI.RequestQuery("refundNo", 0);
            self.data.resultdata = self.GetRefundLogByRefundNo(refundNo);
        }
        else if (funname == "mall.CancelRefund") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.CancelRefund(model);
        } else if (funname == "mall.GetRefundByRefundNo") {
            var refundNo = LobsterAPI.RequestQuery("refundNo", 0);
            var userId = LobsterAPI.RequestQuery("userId", 0);
            self.data.resultdata = self.GetRefundByRefundNo(refundNo, userId);
        }
        else if (funname == "mall.getShopInfo") {
            var shopId = LobsterAPI.RequestQuery("shopId", 0);
            self.data.resultdata = self.getShopInfo(shopId);
        } else if (funname == "mall.ConfirmSendBack") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.ConfirmSendBack(model);
        } else if (funname == "mall.refundsuccess") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.refundsuccess(model);
        } else if (funname == "mall.getbannerlist") {
            self.data.resultdata = self.getbannerlist(model);
        } else if (funname == "mall.getordercount") {
            var userId = LobsterAPI.RequestQuery("userId", 0);
            self.data.resultdata = self.getordercount(userId);
        }
        return self.data.resultdata;
    },
    getgoodslist(page, limit, searchkey, classId, sortkey) {
        var self = this;
        var pageInfo = {};
        LobsterAPI.TrackLog("getgoodslist", sortkey);
        LobsterAPI.TrackLog("getgoodslist", self.data.WorkId);
        if (sortkey)
            pageInfo.key = sortkey;
        else
            pageInfo.key = "GoodsSort";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var dbparams = Packages.java.util.ArrayList();
        var strsql = "select * from Mall_Goods where WorkId=? and GoodsStatus=1";
        dbparams.add(self.data.WorkId);
        LobsterAPI.TrackLog("getgoodslist2", searchkey);
        if ((searchkey || "") != "") {
            strsql += " and (GoodsName like ? or GoodsKey like ?)";
            dbparams.add('%' + searchkey + '%');
            dbparams.add('%' + searchkey + '%');
        }
        if (classId > -1) {
            strsql += " and GoodsClass = ?";
            dbparams.add(classId);
        }
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    getgoodsdetail: function (goodsId) {
        var strsql = "select a.*,b.ShopName from Mall_Goods a\
        inner join Mall_Shop b\
        on a.ShopId=b.ShopId\
        where a.GoodsId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(goodsId);
        var goodsdetail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { goodsdetail: goodsdetail } };
    },
    getevaluatelist: function (page, limit, goodsId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "EvaluateTime desc ";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var dbparams = Packages.java.util.ArrayList();
        var strsql = "select \
        a.OrderEvaluateId,\
        a.UserId,\
        a.GoodsId,\
        a.SpecDetailId,\
        a.SpecName,\
        a.OrderNo,\
        a.Star ,\
        a.Cont,\
        a.Imgs,\
        a.EvaluateTime,\
        a.PublishStatus,\
        a.WorkId,\
        b.NickName as UserName,\
        b.UserImg from Mall_OrderEvaluate a\
        left join Mall_Member b\
        on a.UserId=b.UserId\
        where WorkId=? and GoodsId=?";
        dbparams.add(self.data.WorkId);
        dbparams.add(goodsId);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: { data: data, count: pageInfo.totalRecord } };
    },
    getspeclist: function (goodsId) {
        var strsql = "select * from Mall_GoodsSpec  where GoodsId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(goodsId);
        var speclist = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        strsql = "select * from Mall_GoodsSpecDetail  where GoodsId=?";
        dbparams = Packages.java.util.ArrayList();
        dbparams.add(goodsId);
        var specdetaillist = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);

        return { code: 0, data: { speclist: speclist, specdetaillist: specdetaillist } };
    },
    getcartcount: function (userId) {
        var strsql = "select sum(num) as total from Mall_Cart  where UserId=? and Status=1";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        var cart = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { cartcount: cart.total } }

    },
    getcartlist: function (userId) {
        var strsql = "select a.*,b.GoodsName,c.GoodsSpecImg,c.GoodsMarketPrice,c.GoodsRetailPrice,c.GoodsStock,d.ShopName from Mall_Cart a\
        inner join Mall_Goods b\
        on a.GoodsId=b.GoodsId\
        inner join Mall_Shop d\
        on b.ShopId=d.ShopId\
        left join Mall_GoodsSpecDetail c\
        on a.SpecDetailId=c.GoodsSpecDetailId\
        where a.UserId=? and a.Status=1";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        var list = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { list: list } };
    },
    addcart: function (model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            model.Status = 1;
            model.IsChecked = 1;
            model.WorkId = self.data.WorkId;
            var oldcart = null;
            var detail = null
            var strsql = "select * from Mall_Goods where GoodsId=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.GoodsId);
            var goods = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!goods.GoodsId)
                return { code: 1, msg: "找不到商品数据" }
            if (model.SpecDetailId > 0) {
                strsql = "select * from Mall_Cart where GoodsId=? and SpecDetailId=?\
                 and WorkId=? and UserId=? and Status=1";
                dbparams = Packages.java.util.ArrayList();
                dbparams.add(model.GoodsId);
                dbparams.add(model.SpecDetailId);
                dbparams.add(self.data.WorkId);
                dbparams.add(model.UserId)
                oldcart = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
                // if (!oldcart.CartId)
                //     return { code: 1, msg: "找不到购物车数据" };
                strsql = "select * from Mall_GoodsSpecDetail where GoodsSpecDetailId=? ";
                dbparams = Packages.java.util.ArrayList();
                dbparams.add(model.SpecDetailId);
                detail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
                if (!detail.GoodsSpecDetailId)
                    return { code: 1, msg: "找不到商品规格详情数据" };
            } else {
                strsql = "select * from Mall_Cart where GoodsId=? and WorkId=? and UserId=?  and Status=1";
                dbparams = Packages.java.util.ArrayList();
                dbparams.add(model.GoodsId);
                dbparams.add(self.data.WorkId);
                dbparams.add(model.UserId)
                oldcart = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
                if (!oldcart.CartId)
                    return { code: 1, msg: "找不到购物车数据" };
            }
            LobsterAPI.TrackLog("mall.addcart-detail", detail);
            var dateTime = self.getdatetime();
            if (oldcart.CartId > 0) {
                oldcart.UpdateTime = dateTime;
                oldcart.Num = parseInt(oldcart.Num) + parseInt(model.Num);
                if (detail.GoodsSpecDetailId > 0) {
                    if (parseInt(detail.GoodsStock) < parseInt(oldcart.Num)) {
                        return { code: 1, msg: "商品库存不足" };
                    }
                }
                else {
                    if (parseInt(goods.GoodsStock) < parseInt(oldcart.Num)) {
                        return { code: 1, msg: "商品库存不足" };
                    }
                }
                self.data.CartModel.objval = oldcart;
                LobsterAPI.TrackLog("mall.addcart-oldcart", oldcart);
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.CartModel);
            } else {
                model.CreateTime = dateTime;
                if (detail != null) {
                    if (parseInt(detail.GoodsStock) < parseInt(model.Num)) {
                        return { code: 1, msg: "商品库存不足" };
                    }
                }
                else {
                    if (parseInt(goods.GoodsStock) < parseInt(model.Num)) {
                        return { code: 1, msg: "商品库存不足" };
                    }
                }
                LobsterAPI.TrackLog("mall.addcart-newcart", model);
                self.data.CartModel.objval = model;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.CartModel);
            }
            self.data.dbConn.commit();
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    updatecartchecked: function (model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var list = JSON.parse(model.ids);
            var strsql = "Update Mall_Cart set IsChecked=0 where UserId=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.userId);
            var ret = self.data.dbConn.executeUpdate(strsql, dbparams);
            if (ret < 1)
                throw '更新报错'
            if (list.length > 0) {
                strsql = "Update Mall_Cart set IsChecked=1 Where CartId in (?)";
                dbparams = Packages.java.util.ArrayList();
                dbparams.add(list.join(","));
                ret = self.data.dbConn.executeUpdate(strsql, dbparams);
                if (ret < 1)
                    throw '更新报错'
            }
            self.data.dbConn.commit();
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    updatecartnum: function (model) {
        var self = this;
        try {
            LobsterAPI.TrackLog("updatecartnum----", model);
            var strsql = "select * from Mall_Cart where CartId=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.CartId);
            var cart = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!cart.CartId)
                return { code: 1, msg: "找不到购物车数据" };

            strsql = "select * from Mall_GoodsSpecDetail where GoodsSpecDetailId=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(cart.SpecDetailId);
            var detail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!detail.GoodsSpecDetailId)
                return { code: 1, msg: "找不到商品规格详细数据" };
            cart.Num = model.Num;
            LobsterAPI.TrackLog("updatecartnum", cart);
            if (parseInt(detail.GoodsStock) < parseInt(model.Num))
                return { code: 1, msg: "库存不足" };
            self.data.CartModel.objval = cart;
            LobsterAPI.TrackLog("updatecartnum2", cart);
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.CartModel);
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            return { code: 1, msg: e.message };
        }
    },
    updatecartspec(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            LobsterAPI.TrackLog("updatecartspec---", model);
            var strsql = "select * from Mall_Cart where CartId=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.CartId);
            var cart = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!cart.CartId)
                return { code: 1, msg: "找不到购物车数据" };
            strsql = "select * from Mall_GoodsSpecDetail where GoodsSpecDetailId=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.SpecDetailId);
            var detail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!detail.GoodsSpecDetailId)
                return { code: 1, msg: "找不到商品规格详细数据" };
            strsql = "select * from Mall_Cart where SpecDetailId=? and Status=1 and UserId=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.SpecDetailId);
            dbparams.add(model.UserId);
            var oldcart = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);

            if (oldcart.CartId && oldcart.CartId != cart.CartId) {

                LobsterAPI.TrackLog("updatecartspec-oldcart--------", oldcart);
                cart.Status = 0;
                self.data.CartModel.objval = cart;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.CartModel);
                oldcart.Num = parseInt(oldcart.Num) + parseInt(cart.Num);
                if (parseInt(detail.GoodsStock) < parseInt(oldcart.Num))
                    return { code: 1, msg: "库存不足" };
                self.data.CartModel.objval = oldcart;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.CartModel);
            }
            else {
                cart.SpecDetailId = model.SpecDetailId;
                cart.SpecName = model.SpecName;
                self.data.CartModel.objval = cart;

                LobsterAPI.TrackLog("updatecartspec-newcart--------", cart);
                if (parseInt(detail.GoodsStock) < parseInt(cart.Num))
                    return { code: 1, msg: "库存不足" };
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.CartModel);
            }
            self.data.dbConn.commit();
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    removecart: function (model) {
        var list = JSON.parse(model.ids)
        var strsql = "Update Mall_Cart set Status=0 Where CartId in (" + list.join(",") + ")";
        var ret = self.data.dbConn.executeUpdate(strsql);
        if (ret < 1)
            return { code: 1, msg: "移除失败" };
        else
            return { code: 0, msg: "操作成功" };
    },
    getorderinfo: function (orderNo) {
        var strsql = "select * from mall_order Where OrderNo=? and WorkId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        dbparams.add(self.data.WorkId);
        var data = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { data: data } };
    },
    generateorder: function (model) {
        var self = this;
        var oldorder = JSON.parse(model.order);
        try {
            self.data.dbConn.setAutoCommit(false);
            var strsql = "select * from  Mall_Order Where OrderNo=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(oldorder.OrderNo);
            var order = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (order.OrderId > 0)
                return { code: 0, data: { order: order } };
            var neworderno = self.generateOrderNo();
            self.data.OrderModel.objval = {
                WorkId: self.data.WorkId,
                OrderNo: neworderno,
                CreateTime: self.getdatetime(),
                TotalFee: oldorder.TotalFee,
                PayState: oldorder.TotalFee == 0 ? 2 : 1,
                OrderStatus: 0,
                DelFlag: 0,
                UserId: oldorder.UserId
            };
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderModel);
            if (model.goods != null) {
                var goodslist = JSON.parse(model.goods);
                goodslist.forEach(item => {
                    item.OrderNo = neworderno;
                    self.data.OrderGoodsModel.objval = item;
                    LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderGoodsModel);
                    strsql = "select * from  Mall_GoodsSpecDetail Where GoodsSpecDetailId=?";
                    dbparams = Packages.java.util.ArrayList();
                    dbparams.add(item.SpecDetailId);
                    var detail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
                    if (parseInt(detail.GoodsStock) < parseInt(item.GoodsNum))
                        throw item.GoodsName + '库存不足';
                    detail.GoodsStock = parseInt(detail.GoodsStock) - parseInt(item.GoodsNum);
                    self.data.GoodsSpecDetailModel.objval = detail;
                    LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.GoodsSpecDetailModel);
                    strsql = "select * from  Mall_Cart Where UserId=? and  GoodsId=? and SpecDetailId=? and Status=1";
                    dbparams = Packages.java.util.ArrayList();
                    dbparams.add(oldorder.UserId);
                    dbparams.add(item.GoodsId);
                    dbparams.add(item.SpecDetailId);
                    var cart = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
                    if (cart.CartId > 0) {
                        cart.Status = 0;
                        self.data.CartModel.objval = cart;
                        LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.CartModel);
                    }
                });
            }
            if (model.address != null) {
                var address = JSON.parse(model.address)
                address.OrderNo = neworderno;
                self.data.OrderAddressModel.objval = address;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderAddressModel);
            }
            self.data.dbConn.commit();
            return { code: 0, data: neworderno };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    paysuccess: function (model) {
        var self = this;
        try {
            if (model.OrderType != 3)
                return { code: 0, msg: "操作成功" };
            LobsterAPI.TrackLog("mall.paysuccess1", model)
            self.data.dbConn.setAutoCommit(false);
            var strsql = "select * from  Mall_Order Where OrderNo=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.BusinessOrderNo);
            LobsterAPI.TrackLog("model.BusinessOrderNo", model.BusinessOrderNo);
            var order = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!order.OrderId)
                return { code: 1, msg: "找不到订单" };
            if (order.PayDate == 2)
                return { code: 1, msg: "已经支付" };
            strsql = "update Mall_Order set PayState=2,OrderStatus=1,PayType=? where PayState=1 and OrderId=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.PayType);
            dbparams.add(order.OrderId);
            var ret = self.data.dbConn.executeUpdate(strsql, dbparams);
            if (ret < 1)
                throw '更新报错';
            LobsterAPI.TrackLog("mall.paysuccess2", "11111111111");
            self.data.OrderPayModel.objval = {
                BankType: model.BankType,
                MchId: model.MchId,
                OrderNo: order.OrderNo,
                PayDate: self.getdatetime(),
                PayFee: model.PayFee / 100,
                TimeEnd: self.formateDate("yyyy-MM-dd HH:mm:ss", new Date(model.TimeEnd)),
                TradeNo: model.TradeNo,
            }
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderPayModel);
            LobsterAPI.TrackLog("mall.paysuccess3", "222222222222222");
            strsql = "select * from Mall_OrderGoods where OrderNo=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.BusinessOrderNo);
            var ordergoodslist = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
            ordergoodslist.forEach(a => {
                strsql = "select * from Mall_Goods where GoodsId=?";
                dbparams = Packages.java.util.ArrayList();
                dbparams.add(a.GoodsId);
                var goods = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
                goods.MonthLatestSalesVolume += a.GoodsNum;
                goods.TotalSalesVolume += a.GoodsNum;
                self.data.OrderGoodsModel.objval = goods;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderGoodsModel);
            })
            self.data.dbConn.commit();
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    getorderaddressbyorderno: function (orderNo) {
        var strsql = "select * from  Mall_OrderAddress Where OrderNo=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        var address = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { address: address } };
    },
    getordergoodslist: function (orderNo) {
        var strsql = "select * from  Mall_OrderGoods Where OrderNo=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        var goodslist = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { goodslist: goodslist } };
    },
    getrefundlistbyorderno: function (orderNo) {
        var strsql = "select a.*,b.GoodsId,b.SpecDetailId,b.GoodsNum from Mall_Refund a\
        inner join Mall_RefundGoods b\
        on a.RefundNo=b.RefundNo\
        where a.OrderNo=? and a.RefundType!=3 and a.RefundStatus in(0,1,2,3,4)";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        var refundlist = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { refundlist: refundlist } };
    },
    savemember: function (model) {
        var strsql = "select * from  Mall_Member Where UserId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(model.UserId);
        var member = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        if (member.MemberId > 0) {
            self.data.MemberModel.objval = {
                NickName: model.Nickname,
                UserImg: model.ImgUrl,
                TelPhone: model.MobileNo
            };
        } else {
            self.data.MemberModel.objval = {
                NickName: model.Nickname,
                UserImg: model.ImgUrl,
                UserId: model.UserId,
                TelPhone: model.MobileNo
            };
        }
        LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.MemberModel);
        return { code: 0, msg: "操作成功" };
    },
    getorderlist: function (page, limit, orderStatus, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "CreateTime desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var dbparams = Packages.java.util.ArrayList();
        var strsql = "select a.*,convert(varchar(2000), (SELECT GoodsName+',' from Mall_OrderGoods where OrderNo=a.OrderNo FOR XML PATH(''))) as GoodsName,\
        convert(varchar(2000),(SELECT SpecImg+',' from Mall_OrderGoods where OrderNo=a.OrderNo FOR XML PATH(''))) as SpecImg,\
        convert(varchar(2000),(SELECT CONVERT(varchar(50), GoodsId)+',' from Mall_OrderGoods where OrderNo=a.OrderNo FOR XML PATH(''))) as GoodsId,\
        convert(varchar(2000),(SELECT CONVERT(varchar(50), SpecDetailId)+',' from Mall_OrderGoods where OrderNo=a.OrderNo FOR XML PATH(''))) as SpecDetailId,\
        convert(varchar(2000),(SELECT  SpecName+',' from Mall_OrderGoods where OrderNo=a.OrderNo FOR XML PATH(''))) as SpecName\
         from Mall_Order a \
        where a.WorkId=? and a.UserId=?";
        dbparams.add(self.data.WorkId);
        dbparams.add(userId);
        if (orderStatus > -1) {
            if (orderStatus == 3) {
                strsql += " and a.OrderStatus in(3,4,5,6,7)";
            } else {
                strsql += " and a.OrderStatus=?";
                dbparams.add(orderStatus);
            }
        }
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    getorderlogisticsbyorderno(orderNo) {
        var strsql = "select * from Mall_OrderLogistics where OrderNo=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        var logistics = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { logistics: logistics } };
    },
    refund(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var strsql = "select * from Mall_Order where OrderNo=?";
            var dbparams = Packages.java.util.ArrayList();
            var refund = JSON.parse(model.refund);
            dbparams.add(refund.OrderNo);
            var order = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);

            strsql = "select * from Mall_Refund where OrderNo=? and RefundStatus<4";
            var refunding = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (refunding.RefundId > 0)
                return { code: 1, msg: "申请退款中" };

            var refundNo = "R" + self.generateOrderNo();
            var orderrefund = {
                RefundNo: refundNo,
                OrderNo: refund.OrderNo,
                RefundDate: self.getdatetime(),
                RefundFee: refund.RefundFee,
                RefundType: refund.RefundType,
                RefundDesc: refund.RefundDesc,
                RefundMemo: refund.RefundMemo,
                CargoStatus: refund.CargoStatus,
                UserId: refund.UserId,
                RefundStatus: 0,
                WorkId: self.data.WorkId,
                Imgs: refund.Imgs
            }
            self.data.RefundModel.objval = orderrefund;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.RefundModel);
            // order.RefundNo = refundNo;
            // self.data.OrderModel.objval = order;
            // LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderModel);
            var refundlog =
            {
                OrderNo: order.OrderNo,
                RefundNo: refundNo,
                Memo: "用户申请退款",
                OperationTime: self.getdatetime(),
                Operator: ""
            };
            self.data.RefundLogModel.objval = refundlog;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.RefundLogModel);
            var goods = JSON.parse(model.goods);
            goods.forEach(a => {
                a.OrderNo = order.OrderNo;
                a.RefundNo = refundNo;
                self.data.RefundGoodsModel.objval = a;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.RefundGoodsModel);
            })
            self.data.dbConn.commit();
            return { code: 0, data: { refundNo: refundNo } };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    UpdateOrderStatus(orderNo, orderStatus) {
        var self = this;
        var strsql = "select * from Mall_Order where OrderNo=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        var order = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        if (!order.OrderId)
            return { code: 1, msg: "找不到订单" };
        order.OrderStatus = orderStatus;
        self.data.OrderModel.objval = order;
        LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderModel);
        return {code:0,msg:"操作成功"};
    },
    GetEvaluateListByOrderNo(orderNo) {
        var strsql = "select a.*,b.OrderEvaluateId from Mall_OrderGoods a\
        left join Mall_OrderEvaluate b\
        on a.OrderNo=b.OrderNo and a.GoodsId=b.GoodsId and a.SpecDetailId=b.SpecDetailId\
        where a.OrderNo=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        var list = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { list: list } }
    },
    GetEvaluateDetail(orderNo, goodsId, specDetailId) {
        var strsql = "select  *  from Mall_OrderEvaluate where OrderNo=? and GoodsId=? and SpecDetailId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(orderNo);
        dbparams.add(goodsId);
        dbparams.add(specDetailId);
        var detail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { detail: detail } }
    },
    SaveEvaluate(model) {
        var self = this;
        model.WorkId = self.data.WorkId;
        model.EvaluateTime = self.getdatetime();
        model.PublishStatus = 1;
        self.data.OrderEvaluateModel.objval = model;
        LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderEvaluateModel);
        return {code:0,msg:"操作成功"};
    },
    GetRefundList(page, limit, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "RefundDate desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var dbparams = Packages.java.util.ArrayList();
        var strsql = "select a.*,b.GoodsId,b.GoodsName,b.GoodsNum,b.GoodsPrice,b.SpecDetailId,b.SpecImg,b.SpecName from Mall_Refund a\
        inner join Mall_RefundGoods b\
        on a.RefundNo=b.RefundNo\
        where a.WorkId=? and a.UserId=?";
        dbparams.add(self.data.WorkId);
        dbparams.add(userId);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: { data: data }, count: pageInfo.totalRecord };
    },
    GetRefundByRefundNo(refundNo, userId) {
        var strsql = "select a.*,b.GoodsId,b.GoodsName,b.GoodsNum,b.GoodsPrice,b.SpecDetailId,b.SpecImg,b.SpecName from Mall_Refund a\
        inner join Mall_RefundGoods b\
        on a.RefundNo=b.RefundNo\
        where a.WorkId=? and a.UserId=?  and a.RefundNo=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(self.data.WorkId);
        dbparams.add(userId);
        dbparams.add(refundNo);
        var refund = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { refund: refund } }
    },
    GetRefundLogByRefundNo(refundNo) {
        var strsql = "select * from Mall_RefundLog where RefundNo=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(refundNo);
        var loglist = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { loglist: loglist } }
    },
    CancelRefund(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var strsql = "select * from Mall_Refund where RefundNo=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.RefundNo);
            var refund = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!refund.RefundId)
                return { code: 1, msg: "找不到退款订单" };
            refund.RefundStatus = 9;
            self.data.RefundModel.objval = refund;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.RefundModel);
            var refundlog =
            {
                OrderNo: refund.OrderNo,
                RefundNo: refund.RefundNo,
                Memo: "用户撤销退款",
                OperationTime: self.getdatetime(),
                Operator: ""
            };
            self.data.RefundLogModel.objval = refundlog;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.RefundLogModel);
            self.data.dbConn.commit();
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    getShopInfo(shopId) {
        var strsql = "select * from Mall_ShopLogistics where ShopId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(shopId);
        var shoplogistics = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { shoplogistics: shoplogistics } }
    },
    ConfirmSendBack(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var strsql = "select * from Mall_Refund where RefundNo=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.RefundNo);
            var refund = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!refund.RefundId)
                return { code: 1, msg: "找不到退款订单" };
            refund.RefundStatus = 2;
            self.data.RefundModel.objval = refund;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.RefundModel);
            var refundlog =
            {
                OrderNo: refund.OrderNo,
                RefundNo: refund.RefundNo,
                Memo: "用户寄回",
                OperationTime: self.getdatetime(),
                Operator: ""
            };
            self.data.RefundLogModel.objval = refundlog;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.RefundLogModel);
            model.Status = 1;
            model.OrderNo = refund.OrderNo;
            model.Fee = 0;
            self.data.OrderLogisticsModel.objval = model;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.OrderLogisticsModel);
            self.data.dbConn.commit();
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    refundsuccess(model) {
        LobsterAPI.TrackLog("refundsuccess", model);
        var self = this;
        try {
            if (model.OrderType != 3)
                return { code: 0, msg: "操作成功" };
            self.data.dbConn.setAutoCommit(false);
            var strsql = "select * from Mall_Refund where RefundNo=?";
            var dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.BusinessRefundNo);
            var orderRefund = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!orderRefund.RefundId)
                return { code: 1, msg: "找不到退款订单" };
            strsql = "select * from Mall_Order where OrderNo=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.BusinessOrderNo);
            var order = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
            if (!order.OrderId)
                return { code: 1, msg: "找不到订单" };
            if (orderRefund.RefundType == 3) {
                strsql = "update Mall_Order set PayState=3,OrderStatus=7 where OrderId=?";
                dbparams = Packages.java.util.ArrayList();
                dbparams.add(order.OrderId);
                var ret = self.data.dbConn.executeUpdate(strsql, dbparams);
                if (ret < 1)
                    throw '更新报错';
            }
            strsql = "update Mall_Refund set RefundStatus=4,SuccessTime=? where RefundId=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(self.formateDate("yyyy-MM-dd HH:mm:ss", new Date(model.SuccessTime)));
            dbparams.add(orderRefund.RefundId);
            var ret2 = self.data.dbConn.executeUpdate(strsql, dbparams);
            if (ret2 < 1)
                throw '更新报错';
            strsql = "select * from Mall_RefundGoods where RefundNo=?";
            dbparams = Packages.java.util.ArrayList();
            dbparams.add(model.BusinessRefundNo);
            var goods = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
            goods.forEach(item => {
                strsql = "select * from Mall_GoodsSpecDetail where GoodsSpecDetailId=?";
                dbparams = Packages.java.util.ArrayList();
                dbparams.add(item.SpecDetailId);
                var detail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
                detail.GoodsStock = parseInt(detail.GoodsStock) + parseInt(item.GoodsNum);
                self.data.GoodsSpecDetailModel.objval = detail;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.GoodsSpecDetailModel);
            })
            self.data.dbConn.commit();
            return { code: 0, msg: "操作成功" };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    getbannerlist() {
        var strsql = "select * from Mall_BannerSet where WorkId=? and DelFlag=0 order by sort";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(self.data.WorkId);
        var bannerlist = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { bannerlist: bannerlist } };
    },
    getordercount(userId) {
        var strsql = "select count(0) as count from Mall_Order Where WorkId=? and UserId=? and OrderStatus=0";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(self.data.WorkId);
        dbparams.add(userId);
        var count = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        strsql = "select count(0) as count2 from Mall_Order Where WorkId=? and UserId=? and OrderStatus=2";
        dbparams = Packages.java.util.ArrayList();
        dbparams.add(self.data.WorkId);
        dbparams.add(userId);
        var count2 = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { count: count.count, count2: count2.count2 } }
    },
    getdatetime: function () {
        var self = this;
        return LobsterAPI.getCurrTime(self.data.dbConn, "yyyyMMddhhmmss", 0, 0, 0, 0);
    },
    generateOrderNo: function () {
        var self = this;
        var currentDateStr = LobsterAPI.getCurrTime(self.data.dbConn, "yyyyMMddhhmmss", 0, 0, 0, 0);
        currentDateStr = currentDateStr.replace(/-/gi, "").replace(/:/gi, "").replace(" ", "")
        return currentDateStr + Math.ceil(Math.random() * 1000000);
    },
    formateDate: function (fmt, date) {
        var ret;
        var opt = {
            "y+": date.getFullYear().toString(),
            "M+": (date.getMonth() + 1).toString(),
            "d+": date.getDate().toString(),
            "H+": date.getHours().toString(),
            "m+": date.getMinutes().toString(),
            "s+": date.getSeconds().toString()
        };
        for (var k in opt) {
            ret = new RegExp("(" + k + ")").exec(fmt);
            if (ret) {
                fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
            };
        };
        return fmt;
    },
})